﻿<div class="page-header position-relative">
    <div class="header-title">
        <h1>
            添加管理员
        </h1>
    </div>
    <!--Header Buttons-->
    <div class="header-buttons">
        <a class="sidebar-toggler" href="#">
            <i class="fa fa-arrows-h"></i>
        </a>
        <a class="refresh" id="refresh-toggler" href="">
            <i class="glyphicon glyphicon-refresh"></i>
        </a>
        <a class="fullscreen" id="fullscreen-toggler" href="#">
            <i class="glyphicon glyphicon-fullscreen"></i>
        </a>
    </div>
    <!--Header Buttons End-->
</div>
<!-- /Page Header -->
<!-- Page Body -->
<div class="page-body">

    <div class="row" id="add">
        <div class="row">
            <div class="col-lg-6 col-sm-6 col-xs-12" id="addform">
                <div class="widget">
                    <div class="widget-header bordered-bottom bordered-palegreen">
                        <span class="widget-caption">管理员信息</span>
                    </div>
                    <div class="widget-body">
                        <div>
                            <form class="form-horizontal form-bordered" role="form" id="myform">
                                <div class="form-group">
                                    <label for="inputEmail3" class="col-sm-2 control-label no-padding-right">用户名</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="username"
                                               data-bv-message="The username is not valid"
                                               data-bv-notempty="true"
                                               data-bv-notempty-message="请输入用户名"
                                               data-bv-regexp="true"
                                               data-bv-regexp-regexp="[a-zA-Z0-9_\.]+"
                                               data-bv-regexp-message="用户名只能由字母，数字，点和下划线组成"
                                               data-bv-stringlength="true"
                                               data-bv-stringlength-min="6"
                                               data-bv-stringlength-max="30"
                                               data-bv-stringlength-message="用户名长度必须为6-30位字符"
                                               data-bv-different="true"
                                               data-bv-different-field="password"
                                               data-bv-different-message="用户名不能与密码一致"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputEmail3" class="col-sm-2 control-label no-padding-right">昵称</label>
                                    <div class="col-sm-10">
                                        <input class="form-control" name="nickname" type="text"
                                               data-bv-notempty="true"
                                               data-bv-stringlength-min="1"
                                               data-bv-stringlength-max="18"
                                               data-bv-stringlength-message="昵称长度必须为1-18位字符"
                                               data-bv-notempty-message="请输入昵称"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputEmail3" class="col-sm-2 control-label no-padding-right">密码</label>
                                    <div class="col-sm-10">
                                        <input type="password" class="form-control" name="password"
                                               data-bv-notempty="true"
                                               data-bv-notempty-message="请输入密码"
                                               data-bv-identical="true"
                                               data-bv-identical-field="repassword"
                                               data-bv-identical-message="两次密码不一致"
                                               data-bv-stringlength="true"
                                               data-bv-stringlength-min="6"
                                               data-bv-stringlength-max="18"
                                               data-bv-stringlength-message="密码长度必须为6-18"
                                               data-bv-different="true"
                                               data-bv-different-field="username"
                                               data-bv-different-message="密码不能与用户名一致"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputPassword3"
                                           class="col-sm-2 control-label no-padding-right">确认密码</label>
                                    <div class="col-sm-10">
                                        <input type="password" class="form-control" name="repassword"
                                               data-bv-notempty="true"
                                               data-bv-notempty-message="请输入重复密码"
                                               data-bv-identical="true"
                                               data-bv-identical-field="password"
                                               data-bv-identical-message="两次密码不一致"
                                               data-bv-stringlength-min="6"
                                               data-bv-stringlength-max="18"
                                               data-bv-stringlength-message="密码长度必须为6-18"
                                               data-bv-different="true"
                                               data-bv-different-field="username"
                                               data-bv-different-message="确认密码不能与用户名一致"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-sm-offset-2 col-sm-10">
                                        <button type="submit" class="btn btn-palegreen">提交</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(document).ready(function () {
        $("#myform").bootstrapValidator({
            submitHandler: function (validator, form, submitButton) {
                $.post("{{urlAdmin('admin','postAdd')}}", form.serialize(), function (res) {
                    layer.msg(res.msg,function(){
                        $("button[type='submit']").removeAttr("disabled");
                    });
                }, 'json');
            }
        });
    });

</script>